package com.jeff.android.lab.android;

import com.jeff.android.lab.BaseRecyclerViewFragment;
import com.jeff.android.lab.android.immerse.ImmerseImageActivity;
import com.jeff.android.lab.android.ipc.MessengerFragment;
import com.jeff.android.lab.android.lazy.LazyFragmentActivity;
import com.jeff.android.lab.android.lifecycle.LifecycleFragment;
import com.jeff.android.lab.android.media.MediaPlayerFragment;
import com.jeff.android.lab.android.storage.StorageFragment;
import com.jeff.android.lab.android.touchevent.TouchEventFragment;
import com.jeff.android.lab.util.RouterUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: duff
 * @date: 2019/1/17
 * @since: 1.0.0
 */
public class AndroidMainFragment extends BaseRecyclerViewFragment {

    @Override
    protected List<String> getData() {
        return new ArrayList<String>() {
            {
                add("storage");
                add("media");
                add("touchevent"); // 事件分发
                add("immerse");
                add("LazyFragment"); // Fragment 懒加载
                add("ipc"); // 进程间通信
                add("lifecycle"); //
            }
        };
    }

    @Override
    protected void launch(String widget) {
        if ("storage".equals(widget)) {
            RouterUtil.launchFragmentActivity(getContext(), StorageFragment.class);
        } else if ("media".equals(widget)) {
            RouterUtil.launchFragmentActivity(getContext(), MediaPlayerFragment.class);
        } else if ("touchevent".equals(widget)) {
            RouterUtil.launchFragmentActivity(getContext(), TouchEventFragment.class);
        } else if ("immerse".equals(widget)) {
            RouterUtil.launchActivity(getContext(), ImmerseImageActivity.class);
        } else if ("LazyFragment".equals(widget)) {
            RouterUtil.launchActivity(getContext(), LazyFragmentActivity.class);
        } else if ("ipc".equals(widget)) {
            RouterUtil.launchFragmentActivity(getContext(), MessengerFragment.class);
        } else if ("lifecycle".equals(widget)) {
            RouterUtil.launchFragmentActivity(getContext(), LifecycleFragment.class);
        }
    }

}
